<template>
    <div class="container">
        <aside>
            <el-menu router>
                <el-menu-item :key="(item.index)" v-for="(item) in menus" :index="item.path"><i class="el-icon-platform-eleme"></i>{{item.route_cn_name}}</el-menu-item>                    
            </el-menu>
        </aside>
        <div class="box">
            <header>{{$store.state.user.nickname}}<el-button @click="logout">退出</el-button></header>
            <main>
                <slot>
                </slot>
            </main>
        </div>
    </div>
</template>

<script>
export default {
    computed:{
        menus() {
            return this.$store.state.user.menuPermissions
        }
    },
    methods: {
        logout() {
            localStorage.removeItem('token')
            this.$router.push('/login')
        }
    }
}
</script>

<style >
.container {
    display: flex;
    width: 100vw;
    height: 100vh;
}
.el-menu {
    height: 100vh;
}
aside{
    width: 140px;
    height: 100vh;
    overflow: auto;
    text-align: center;
}
.box{
    flex:1;
    display: flex;
    flex-direction: column;
    height: 100vh;
}
header{
    height: 60px;
    line-height:60px;
    border-bottom: 1px solid #eee;
}
main{
    flex:1;
    box-sizing: border-box;
    padding: 15px;
    overflow: auto;
}
</style>